<!DOCTYPE html>
<html lang="en">
	<?php $this->load->view('vheader');?>
	<body>
		<?php $this->load->view('vnavbar'); ?>
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<?php $this->load->view('vsidebar'); ?>
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="#">Edit Data Customer</a>
							</li>
							<!--
							<li class="active">Dashboard</li>
							-->
						</ul><!-- .breadcrumb -->

						<div class="nav-search" id="nav-search">

						</div><!-- #nav-search -->
					</div>

					<div class="page-content">
						
						<div class="page-header">
							<h1>
								Tambah Data Customer
								<!--
								<small>
									<i class="icon-double-angle-right"></i>
									overview &amp; stats
								</small>
								-->
							</h1>
						</div><!-- /.page-header -->
						
						<form id="forminputdata" action="<?= site_url() ?>/customer/Ftambahcustomer" class="form-horizontal" role="form" method="post">
						<?php if ($this->uri->segment(3) == 'y'){ ?>
							<div class="alert alert-block alert-success">
								<button data-dismiss="alert" class="close" type="button">
									<i class="icon-remove"></i>
								</button>
						
								<p>
									<strong>
										<i class="icon-ok"></i>
										Penyimpanan Data Berhasil!
									</strong>
									Anda telah berhasil menambahkan data customer, silakan menambahkan data customer lainnya
								</p>
						
							</div>
						<?php } ?>
						<div class="col-xs-12">
							<div id="recent-box" class="widget-box transparent">
						
								<div class="widget-body">
									<div class="widget-main padding-4">
										<div class="tab-content padding-8 overflow-visible">
											<div class="space-4"></div>
											<div class="form-group">
												<?php $customer = $query->result(); ?>
												<input type="hidden" id="id_customer" name="id_customer" value="<?= $customer[0]->id_customer ?>" />
												<label class="col-sm-3 control-label no-padding-right" for="nama_customer"> Nama Customer </label>
											
												<div class="col-sm-9">
													<input type="text" name="nama_customer" id="nama_customer" placeholder="Nama Customer" class="col-xs-10 col-sm-5" value="<?= $customer[0]->nama_customer ?>" />
												</div>
											</div>
						
											<div class="space-4"></div>
											<div class="form-group">
												<label class="col-sm-3 control-label no-padding-right" for="keterangan"> Keterangan </label>
											
												<div class="col-sm-9">
													<input type="text" name="keterangan" id="keterangan" placeholder="Keterangan" class="col-xs-10 col-sm-5" value="<?= $customer[0]->keterangan ?>" />
												</div>
											</div>
										
										</div>
									</div><!-- /widget-main -->
								</div><!-- /widget-body -->
							</div><!-- /widget-box -->
						</div>
						<!--<form id="formsimpandata" action="<?= site_url() ?>/home/fPSaveData">-->
						<div class="col-xs-12">
							<div class="clearfix form-actions">
								<div class="col-md-offset-3 col-md-9">
									<button id="simpan" class="btn btn-info" type="button">
										<i class="icon-ok bigger-110"></i>
										Simpan
									</button>  
									<!--	
									&nbsp; &nbsp; &nbsp;
									<button class="btn" type="reset">
										<i class="icon-undo bigger-110"></i>
										Reset
									</button>
									-->
								</div>
							</div>
						</div>


					</div><!-- /.page-content -->
				</div><!-- /.main-content -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='<?= base_url() ?>assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='<?= base_url() ?>assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
      		$(document).ready(function(){
            	$("#simpan").click(function(){
            		var id_customer= $("#id_customer").val();
            		var nama_customer= $("#nama_customer").val();
            		var keterangan= $("#keterangan").val();
            		
            		var dataString = 'id_customer='+ id_customer +'&nama_customer='+ nama_customer +'&keterangan='+ keterangan;
            		// alert(dataString);
            		if(nama_customer == '')
            		{
            			alert("Nama customer tidak boleh kosong");
            		}
            		else
            		{            		
            			$.ajax({
            				type: "POST",
            				url:siteUrl+'/customer/updatecustomer/'+id_customer,
            				data: dataString,
            				cache: false,
            				success: function(result)
            				{
            				    window.location = siteUrl+"/customer";
            				}
            			});
            		}
            		return false;
            	});
            });
        </script> 

	</body>
</html>
